# -*- coding: utf-8 -*-

'''
    【简介】
	PySide6中 QLineEdit的输入掩码例子
  
'''

from PySide6.QtWidgets import (QApplication,
                               QWidget,
                               QLineEdit,
                               QFormLayout)

import sys

class lineEditDemo(QWidget):
    def __init__(self,parent=None):
        super(lineEditDemo,self).__init__(parent)
        self.setWindowTitle('QLineEdit的输入掩码例子')
        
        flo = QFormLayout()
        
        pIPLineEdit = QLineEdit()
        pMACLineEdit = QLineEdit()
        pDateLineEdit = QLineEdit()
        pLicenseLineEdit = QLineEdit()
        
        # 设置输入掩码
        pIPLineEdit.setInputMask('000.000.000.000;_')
        pMACLineEdit.setInputMask('HH:HH:HH:HH:HH:HH;_')
        pDateLineEdit.setInputMask('0000-00-00;_')
        pLicenseLineEdit.setInputMask(">AAAAA-AAAAA-AAAAA-AAAAA-AAAAA#")
        
        # 添加掩码提示
        flo.addRow('数字掩码',pIPLineEdit)
        flo.addRow('Mac掩码',pMACLineEdit)
        flo.addRow('日期掩码',pDateLineEdit)
        flo.addRow('许可证掩码',pLicenseLineEdit)
        
        
        # 添加掩码提示
        pIPLineEdit.setToolTip("ip: 192.168.*")
        pMACLineEdit.setToolTip("mac: HH:HH:HH:*")
        pDateLineEdit.setToolTip("date: YYYY-MM-DD")
        pLicenseLineEdit.setToolTip("许可证: HDFG-ADDB-*")
        
        self.setLayout(flo)
        
        
        
        
if __name__ == '__main__':
    app = QApplication(sys.argv)
    main_window = lineEditDemo()
    main_window.show()
    sys.exit(app.exec())